using Shared; using System; using System.Collections.Generic; using System.Text; using HDL_ON.UI.CSS; using HDL_ON.Entity; using HDL_ON.DriverLayer; using HDL_ON.UI.Music; using HDL_ON.UI.UI2.FuntionControlView.VideoDoorLock; using HDL_ON.UI.UI2.Intelligence.Automation; using System.Linq; using HDL_ON.UI.UI2.FuntionControlView.Aks.CommonView; using HDL_ON.UI.UI2.FuntionControlView.Aks.Entity; namespace HDL_ON.UI.UI2.FuntionControlView.HisenseTV { /// /// 海信电视界面 /// public class HisenseTvPage : BaseFramLayout { #region ■ 变量声明___________________________ /// /// 设备 /// private Function device; /// /// 上一级界面的设备名字控件 /// private Button btnDeviceName; /// /// 上一级界面的房间名字控件 /// private Button btnRoomName; /// /// 头部布局 /// private TopView topView; /// /// 当前设备名称 /// private Button btnCurrDeviceName; /// /// 区域 /// private Button btnCurrDeviceRoom; /// ///收藏图标 /// private Button btnCollectIcon; /// /// 门锁状态 /// private Button btnDoorLockIcon; /// /// 表示来自那个界面 /// private CommonMethod.Comerom comerom; /// /// 删除设备后需要更新界面的回调 /// public Action action; #endregion /// /// 构造函数 /// /// 设备 /// 上一级界面的设备名字控件(注:不能传null,没有可以传new Button()) /// 上一级界面的房间名字控件(注:不能传null,没有可以传new Button()) public HisenseTvPage(Function function, Button btnDeviceName, Button btnRoomName, CommonMethod.Comerom comerom, Action action) { this.device = function; this.btnDeviceName = btnDeviceName; this.btnRoomName = btnRoomName; this.comerom = comerom; this.action = action; } public void Show() { //初始化UI this.InitUI(); //初始化事件 this.EventListener(); //读取数据 this.ReadData(); } /// /// 初始化界面 /// private void InitUI() { #region ---界面布局--- this.BackgroundColor = MusicColor.ViewColor; this.topView = new TopView(); this.topView.setBtn.Visible = true; this.topView.topNameBtn.TextID = StringId.dianshi; this.AddChidren(topView.TopFLayoutView()); var vv = new VerticalScrolViewLayout { Y = topView.fLayout.Bottom, Height = Application.GetRealHeight(H_W.H - H_W.T_Height), }; this.AddChidren(vv); var baseFL = new BaseFramLayout(); vv.AddChidren(baseFL); var backgroundFl = new FrameLayout { Y = Application.GetRealHeight(24), X = Application.GetRealWidth(24), Height = Application.GetRealHeight(682), Width = Application.GetRealWidth(327), BackgroundImagePath = "HisenseTv/onbj.png", Name = "backgroundFl", }; baseFL.AddChidren(backgroundFl); baseFL.AdjustRealHeight(51); btnCollectIcon = new Button { X = Application.GetRealWidth(273), Y = Application.GetRealHeight(14), Width = Application.GetRealWidth(40), Height = Application.GetRealWidth(40), UnSelectedImagePath = "MusicIcon/collect.png", SelectedImagePath = "MusicIcon/collectSelected.png", IsSelected = this.device.collect, Name = "collect" }; backgroundFl.AddChidren(btnCollectIcon); btnCurrDeviceName = new Button { TextSize = TextSize.Text24, TextColor = MusicColor.Text18Color, Width = Application.GetRealWidth(160), Height = Application.GetRealHeight(33), Y = Application.GetRealHeight(16), X = Application.GetRealWidth(16), Text = this.device.name, TextAlignment = TextAlignment.CenterLeft, IsBold = true }; backgroundFl.AddChidren(btnCurrDeviceName); btnCurrDeviceRoom = new Button { TextSize = TextSize.Text12, TextColor = MusicColor.MusicNoTxetColor, Width = Application.GetRealWidth(160), Height = Application.GetRealHeight(17), Y = btnCurrDeviceName.Bottom + Application.GetRealHeight(4), X = Application.GetRealWidth(16), Text = this.device.GetRoomListName(), TextAlignment = TextAlignment.CenterLeft, }; backgroundFl.AddChidren(btnCurrDeviceRoom); int yHeight = btnCurrDeviceRoom.Bottom + Application.GetRealHeight(16); var shouyeFL = new CustomFrameLayout(); backgroundFl.AddChidren(shouyeFL); shouyeFL.X = Application.GetRealWidth(24); shouyeFL.Y = yHeight; shouyeFL.AddImageView(); shouyeFL.AddTextButtonView(); shouyeFL.GetImageButton().UnSelectedImagePath = "HisenseTv/shouye.png"; shouyeFL.GetTextButton().Text = "首页"; var kaiguanFL = new CustomFrameLayout(); backgroundFl.AddChidren(kaiguanFL); kaiguanFL.X = shouyeFL.Right + Application.GetRealWidth(37); kaiguanFL.Y = yHeight; kaiguanFL.AddImageView(); kaiguanFL.AddTextButtonView(); kaiguanFL.GetImageButton().UnSelectedImagePath = "HisenseTv/kaiguan.png"; kaiguanFL.GetTextButton().Text = "关机"; var caidanFL = new CustomFrameLayout(); backgroundFl.AddChidren(caidanFL); caidanFL.X = kaiguanFL.Right + Application.GetRealWidth(37); caidanFL.Y = yHeight; caidanFL.AddImageView(); caidanFL.AddTextButtonView(); caidanFL.GetImageButton().UnSelectedImagePath = "HisenseTv/caidan.png"; caidanFL.GetTextButton().Text = "菜单"; var yinliangFL = new FrameLayout(); backgroundFl.AddChidren(yinliangFL); yinliangFL.Height = Application.GetRealHeight(200); yinliangFL.Width = Application.GetRealWidth(68); yinliangFL.Y = shouyeFL.Bottom + Application.GetRealHeight(24); yinliangFL.X = shouyeFL.X; yinliangFL.BackgroundColor = 0xffF2F3F7; yinliangFL.Radius = (uint)Application.GetRealHeight(34); Button btn_jia = new Button { Width = Application.GetRealWidth(32), Height = Application.GetRealWidth(32), UnSelectedImagePath = "HisenseTv/yingliangjia.png", Y = Application.GetRealHeight(20), Gravity = Gravity.CenterHorizontal, }; yinliangFL.AddChidren(btn_jia); Button btnText = new Button { Y = Application.GetRealHeight(90), Height = Application.GetRealHeight(20), Text = "音量", TextColor = MusicColor.TextColor, TextSize = TextSize.Text14, Gravity = Gravity.CenterHorizontal, }; yinliangFL.AddChidren(btnText); Button btn_jian = new Button { Y = Application.GetRealHeight(148), Width = Application.GetRealWidth(32), Height = Application.GetRealWidth(32), UnSelectedImagePath = "HisenseTv/yingliangjian.png", Gravity = Gravity.CenterHorizontal, }; yinliangFL.AddChidren(btn_jian); CustomButton bofangBtn = new CustomButton(); bofangBtn.Text = "播放"; bofangBtn.Y = shouyeFL.Bottom + Application.GetRealHeight(24); bofangBtn.X = yinliangFL.Right + Application.GetRealWidth(37); backgroundFl.AddChidren(bofangBtn); CustomButton zantingBtn = new CustomButton(); zantingBtn.Text = "暂停"; zantingBtn.Y = shouyeFL.Bottom + Application.GetRealHeight(24); zantingBtn.X = bofangBtn.Right + Application.GetRealWidth(37); backgroundFl.AddChidren(zantingBtn); CustomButton kuaijinBtn = new CustomButton(); kuaijinBtn.Text = "快进"; kuaijinBtn.Y = bofangBtn.Bottom + Application.GetRealHeight(16); kuaijinBtn.X = yinliangFL.Right + Application.GetRealWidth(37); backgroundFl.AddChidren(kuaijinBtn); CustomButton kauituiBtn = new CustomButton(); kauituiBtn.Text = "快退"; kauituiBtn.Y = bofangBtn.Bottom + Application.GetRealHeight(16); kauituiBtn.X = kuaijinBtn.Right + Application.GetRealWidth(37); backgroundFl.AddChidren(kauituiBtn); CustomButton jingyinBtn = new CustomButton(); jingyinBtn.Text = "静音"; jingyinBtn.Y = kuaijinBtn.Bottom + Application.GetRealHeight(16); jingyinBtn.X = yinliangFL.Right + Application.GetRealWidth(37); backgroundFl.AddChidren(jingyinBtn); CustomButton shezhiBtn = new CustomButton(); shezhiBtn.Text = "设置"; shezhiBtn.Y = kuaijinBtn.Bottom + Application.GetRealHeight(16); shezhiBtn.X = jingyinBtn.Right + Application.GetRealWidth(37); backgroundFl.AddChidren(shezhiBtn); CustomButton jiechujingyinBtn = new CustomButton(); jiechujingyinBtn.Text = "解除静音"; jiechujingyinBtn.Y = jingyinBtn.Bottom + Application.GetRealHeight(16); jiechujingyinBtn.X = yinliangFL.Right + Application.GetRealWidth(37); backgroundFl.AddChidren(jiechujingyinBtn); CustomButton fanhuiBtn = new CustomButton(); fanhuiBtn.Text = "返回"; fanhuiBtn.Y = jingyinBtn.Bottom + Application.GetRealHeight(16); fanhuiBtn.X = jiechujingyinBtn.Right + Application.GetRealWidth(37); backgroundFl.AddChidren(fanhuiBtn); TypeFrameLayout typeFrameLayout = new TypeFrameLayout(); typeFrameLayout.middLayout.Y = yinliangFL.Bottom + Application.GetRealHeight(32); typeFrameLayout.AddView(backgroundFl); MuenFrameLayout muenFrameLayout = new MuenFrameLayout (); muenFrameLayout.AddView(backgroundFl); muenFrameLayout.parentFl.Y = Application.GetRealHeight(482); muenFrameLayout.parentFl.X = Application.GetRealWidth(73); typeFrameLayout.SetLfteClickListener((btn) => { }); typeFrameLayout.SetRightClickListener((btn) => { }); muenFrameLayout.SetLeftClickListener((b) => { }); #endregion } /// /// 注册事件 /// private void EventListener() { //返回 this.topView.clickBackBtn.MouseUpEventHandler += (sender, e) => { this.RemoveFromParent(); }; //设置 this.topView.clickSetBtn.MouseUpEventHandler += (sender, e) => { CommonMethod.Current.MainThread(() => { //调用秀绕的界面 var infoView = new UI.FunctionBaseInfoSetPage(this.device, () => { if (this.btnDeviceName == null || this.btnRoomName == null || this.device == null) { return; } ////刷新显示 this.btnDeviceName.Text = this.device.name; this.btnRoomName.Text = this.device.GetRoomListName(); this.btnCurrDeviceName.Text = this.device.name; this.btnCurrDeviceRoom.Text = this.device.GetRoomListName(); this.CalculatedPosition();//重新计算宽度 }); infoView.actionDel += () => { //解绑设备后 this.RemoveFromParent(); this.action?.Invoke(); }; MainPage.BasePageView.AddChidren(infoView); infoView.LoadPage(); MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; }); }; //收藏 this.btnCollectIcon.MouseUpEventHandler += (sender, e) => { btnCollectIcon.IsSelected = this.device.collect = !btnCollectIcon.IsSelected; this.device.CollectFunction(); }; } /// /// 初始数据 /// private void ReadData() { CommonMethod.Current.Loading.Start(); CommonMethod.Current.SunThread(() => { try { CommonMethod.Current.MainThread(() => { }); } catch { } finally { Application.RunOnMainThread(() => { CommonMethod.Current.Loading.Hide(); }); } }); } /// /// 重新计算宽度(设备名称,房间控件) /// private void CalculatedPosition() { this.btnCurrDeviceName.Width = this.btnCurrDeviceName.GetTextWidth(); this.btnCurrDeviceName.Width += 10; if (this.btnCurrDeviceName.GetTextWidth() > this.btnCollectIcon.X) { //重新计算宽度 this.btnCurrDeviceName.Width = this.btnCollectIcon.X + Application.GetRealWidth(-10); } this.btnCurrDeviceRoom.Width = this.btnCurrDeviceRoom.GetTextWidth(); this.btnCurrDeviceRoom.Width += 10; if (this.btnCurrDeviceRoom.GetTextWidth() > this.btnCollectIcon.X) { //重新计算宽度 this.btnCurrDeviceRoom.Width = this.btnCollectIcon.X + Application.GetRealWidth(-20 - 10); } //this.cellFrame.X = this.btnCurrDeviceRoom.Right + Application.GetRealWidth(20); } } /// /// 自定义(首页,关机,菜单)容器 /// class CustomFrameLayout : FrameLayout { public const int widthFrameLayout = 68; public const int heightFrameLayout = 68 + 8 + 20; public const int interval = 37;//行中的列间隔值 public CustomFrameLayout(int width = widthFrameLayout, int height = heightFrameLayout) { this.Width = Application.GetRealWidth(width); this.Height = Application.GetRealHeight(height); } Button btnImage = new Button { Width = Application.GetRealWidth(68), Height = Application.GetRealWidth(68), Gravity = Gravity.TopCenter, Name = "btnImage", }; Button btnText = new Button { Width = Application.GetRealWidth(68), Height = Application.GetRealWidth(20), TextID = StringId.dangqianmenweiguan, TextSize = TextSize.Text14, TextColor = MusicColor.TextColor, TextAlignment = TextAlignment.Center, Gravity = Gravity.CenterHorizontal, Name = "btnText", IsMoreLines = true, }; public void AddImageView() { this.AddChidren(btnImage); } public void AddTextButtonView() { btnText.Y = Application.GetRealHeight(8) + btnImage.Bottom; this.AddChidren(btnText); } public Button GetImageButton() { return this.btnImage; } public Button GetTextButton() { return this.btnText; } /// /// 事件监听方法 /// /// 回调(第一个是父类对象;第二个是图标对象;第三个是状态对象 /// 注意:在SetClickListener()前面调用AddImageView()才有效 /// 注意:在SetClickListener()前面调用AddImageView()才有效 public void SetClickListener(Action action) { EventHandler DownClick = (sender, e) => { this.BackgroundColor = 0xFFF2F3F7; action?.Invoke(this, btnImage, btnText); }; this.MouseDownEventHandler += DownClick; btnImage.MouseDownEventHandler += DownClick; btnText.MouseDownEventHandler += DownClick; EventHandler UpClick = (sender, e) => { this.BackgroundColor = 0x00000000; }; this.MouseUpEventHandler += UpClick; btnImage.MouseUpEventHandler += UpClick; btnText.MouseUpEventHandler += UpClick; } } /// /// 按键容器 /// class CustomButton : Button { public CustomButton() { this.Width = Application.GetRealWidth(68); this.Height = Application.GetRealHeight(38); this.TextSize = 14; this.TextColor = MusicColor.TextColor; this.TextAlignment = TextAlignment.Center; this.IsMoreLines = true; this.BackgroundColor = 0xffECEDEE; this.Radius = (uint)Application.GetRealHeight(30); } /// /// 事件监听方法 /// /// 回调(第一个是父类对象 public void SetClickListener(Action